/****************************************Copyright (c)**************************************************
**                                         2016-03
**
**                                
**
**
**--------------File Info-------------------------------------------------------------------------------
** File name:		    ht6x1x_tmr.h
** Last modified Date:  2016-03-29
** Last Version:		v1.0
** Descriptions:		
**
**------------------------------------------------------------------------------------------------------
** Created by:			Evan Chen
** Created date:		2016-03-29
** Version:				v1.0
** Descriptions:		
**
**------------------------------------------------------------------------------------------------------
** Modified by:
** Modified date:
** Version:
** Descriptions:
**
********************************************************************************************************/

/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __HT6X1X_TMR_H
#define __HT6X1X_TMR_H

#ifdef __cplusplus
 extern "C" {
#endif

/* Includes ------------------------------------------------------------------*/
#include "ht60xx.h"

/*TMRCON*/
#define TMRCON_PWMHL_MASK       	((uint16_t)0x0040)
#define TMRCON_PWMHL_HIGH     		((uint16_t)0x0000)
#define TMRCON_PWMHL_LOW      		((uint16_t)0x0040)

#define TMRCON_PWMC_MASK       		((uint16_t)0x0030)
#define TMRCON_PWMC_UP     			((uint16_t)0x0000)
#define TMRCON_PWMC_DOWN     		((uint16_t)0x0010)
#define TMRCON_PWMC_MID     		((uint16_t)0x0020)

#define TMRCON_CCMODE_MASK       	((uint16_t)0x0008)
#define TMRCON_CCMODE_RAISE  		((uint16_t)0x0000)
#define TMRCON_CCMODE_FAIL    		((uint16_t)0x0008)

#define TMRCON_MODE_MASK       		((uint16_t)0x0006)
#define TMRCON_MODE_NONE  		((uint16_t)0x0000)
#define TMRCON_MODE_PWM    		((uint16_t)0x0002)
#define TMRCON_MODE_CAP  			((uint16_t)0x0004)
#define TMRCON_MODE_PRD    		((uint16_t)0x0006)

#define TMRCON_CNTEN_MASK       	((uint16_t)0x0001)
#define TMRCON_CNTEN_DIS  		((uint16_t)0x0000)
#define TMRCON_CNTEN_EN   		((uint16_t)0x0001)

/*TMRDIV*/
#define TMRDIV_MASK       			((uint16_t)0xFFFF)

/*TMRDIV*/
#define TMRPRD_MASK       			((uint16_t)0xFFFF)

/*TMRDIV*/
#define TMRCAP_MASK       			((uint16_t)0xFFFF)

/*TMRCNT*/
#define TMRCNT_MASK       			((uint16_t)0xFFFF)

/*TMRCMP*/
#define TMRCMP_MASK       			((uint16_t)0xFFFF)

/*TMRIE*/
#define CMPIE_CMPIE_MASK       		((uint16_t)0x0004)
#define CMPIE_CMPIE_DIS     			((uint16_t)0x0000)
#define CMPIE_CMPIE_EN      			((uint16_t)0x0004)

#define CMPIE_CAPIE_MASK       		((uint16_t)0x0002)
#define CMPIE_CAPIE_DIS     			((uint16_t)0x0000)
#define CMPIE_CAPIE_EN      			((uint16_t)0x0002)

#define CMPIE_PRDIE_MASK       		((uint16_t)0x0001)
#define CMPIE_PRDIE_DIS     			((uint16_t)0x0000)
#define CMPIE_PRDIE_EN      			((uint16_t)0x0001)

#define CMPIE_ALL_MASK			((uint16_t)0x0007)

/*TMRIF*/
#define CMPIF_CMPIF_MASK       		((uint16_t)0x0004)
#define CMPIF_CAPIF_MASK       		((uint16_t)0x0002)
#define CMPIF_PRDIF_MASK       		((uint16_t)0x0001)

typedef enum
{
	TMR_Enable_CMP = CMPIE_CMPIE_MASK,	
	TMR_Enable_CAP = CMPIE_CAPIE_MASK,
	TMR_Enable_PRD = CMPIE_PRDIE_MASK,
	TMR_Enable_ALL = CMPIE_ALL_MASK
} TMR_Enable_TypeDef;

void TMR_Enable(HT_TMR_TypeDef  *TMRx);
void TMR_Disable(HT_TMR_TypeDef  *TMRx);
void TMR_EnableInterrupt(HT_TMR_TypeDef  *TMRx, TMR_Enable_TypeDef TMRx_Type);
void TMR_DisableInterrupt(HT_TMR_TypeDef  *TMRx, TMR_Enable_TypeDef TMRx_Type);


#ifdef __cplusplus
}
#endif

#endif /* __HT6X1X_TMR_H */

